<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>22Vue中的Js动画与Velocityjs的结合.html</title>
    <script src="./vue.js"></script>
    <script src="https://raw.githubusercontent.com/julianshapiro/velocity/master/velocity.min.js"></script>
</head>

<body>
    <div id="app">
        <transition name="fade" @before-enter="handleBeforeEnter" @enter="handleEnter" @after-enter="handleAfterEnter">
            <div v-show="show">hello world</div>
        </transition>
        <button @click="show = !show">change</button>
    </div>
    <script>
        var vm = new Vue({
            el: "#app",
            data: {
                show: true
            },
            methods: {
                handleBeforeEnter: function (el) {
                    el.style.opacity = 0
                },
                handleEnter: function (el, done) {
                    Velocity(el, { opacity: 1 }, { duration: 1000, complete: done })
                },
                handleAfterEnter: function (el) {
                    console.log('动画结束');
                }
            },
        })
    </script>
</body>

</html>